import consumption.Consumption;
import consumption.DefaultConsume;
import consumption.NormalConsume;
import consumption.SuperConsume;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * 消费工厂
 * @author lty
 */
public class ConsumptionFactory {

    private static final Map<GradeEnum, Consumption> consumptionMap = new HashMap<GradeEnum, Consumption>() {{
        put(GradeEnum.DEFAULT, new DefaultConsume());
        put(GradeEnum.NORMAL, new NormalConsume());
        put(GradeEnum.SUPER, new SuperConsume());
    }};

    public static Consumption getConsumption(GradeEnum gradeEnum) {
        gradeEnum = Optional.ofNullable(gradeEnum).orElse(GradeEnum.DEFAULT);
        return consumptionMap.get(gradeEnum);
    }

    private ConsumptionFactory() {

    }
}
